<template>
	<PopupTemplate className="confirm_order_container" title="立即审核" type="1" :closeable="true" :visible="visible"
		@update:visible="handleUpdate">
		<view class="mt_24">
			<u--form labelPosition="left" labelWidth="auto" :model="formData" :rules="rules" ref="uForm">
				<u-form-item label="订单原金额" labelPosition="top" ref="item1">
					<view class="mt_8">
						<u--input placeholder="请输入订单原金额" :value="data.originalPrice" border="none" type="number"
							readonly></u--input>
					</view>
				</u-form-item>
				<u-form-item label="平台优惠" labelPosition="top" ref="item1">
					<view class="mt_8">
						<u--input placeholder="请输入平台优惠" :value="data.platformDiscount" border="none" type="number"
							readonly></u--input>
					</view>
				</u-form-item>
				<u-form-item label="当前金额" labelPosition="top" ref="item1">
					<view class="mt_8">
						<u--input placeholder="请输入当前金额" :value="data.payAmount" border="none" type="number"
							readonly></u--input>
					</view>
				</u-form-item>
				<u-form-item label="审核结果" prop="isPass" labelPosition="top" ref="item1">
					<view class="mt_8">
						<u-radio-group v-model="formData.isPass" placement="row">
							<u-radio activeColor="#F08519" label="通过" :name="1"></u-radio>
							<view class="width_16">

							</view>
							<u-radio activeColor="#F08519" label="不通过" :name="0"></u-radio>
						</u-radio-group>
					</view>
				</u-form-item>
				<u-form-item label="审核备注（选填）" prop="remark" labelPosition="top" ref="item1">
					<view class="mt_8">
						<u--input placeholder="请输入备注" v-model="formData.remark" maxlength="60" border="none"
							clearable></u--input>
					</view>
				</u-form-item>
			</u--form>
			<view class="mt_26">
				<button class="custom_btn primary w100 fz_14 br_27 lh_40" @click="handleConfirm">立即审核</button>
			</view>
		</view>
	</PopupTemplate>
</template>

<script>
	import PopupTemplate from '@/components/PopupTemplate.vue'
	export default {
		props: {
			visible: {
				type: Boolean,
				default: false
			},
			data: {
				type: Object,
				default: () => ({})
			}
		},
		components: {
			PopupTemplate
		},
		data() {
			return {
				formData: {
					isPass: null,
					remark: ''
				},
				rules: {
					'isPass': [{
						type: 'number',
						required: true,
						message: '请选择审核结果',
						trigger: ['blur', 'change']
					}]
				},
			}
		},
		watch: {
			visible: {
				handler(newVal) {
					if (!newVal) {
						this.formData = {
							isPass: null,
							remark: ''
						}
					}
				}
			}
		},
		methods: {
			handleUpdate(e) {
				this.$emit('update:visible', e)
			},
			handleConfirm() {
				this.$refs.uForm.validate().then(res => {
					this.$emit('confirm', this.data, this.formData)
				}).catch(errors => {})
			}
		}
	}
</script>

<style lang="scss">
	input {
		padding: 12rpx !important;
		background-color: #F6F6F6;
		border-radius: 16rpx;
	}
</style>